package com.ruben.features;

import java.io.*;

/**
 * try案例
 *
 * @author <achao1441470436@gmail.com>
 * @since 2021/7/18 18:37
 */
public class TryDemo {
    private static final String FILE_PATH = "D:/file/files/ps/2077.png";
    private static final String TARGET_PATH = "D:/file/files/ps/1977.png";

    public static void main(String[] args) throws Exception {
        InputStream dataInputStream = new FileInputStream(FILE_PATH);
        OutputStream output = new FileOutputStream(TARGET_PATH);
        try (dataInputStream; output) {
            byte[] buffer = new byte[1024];
            int length;
            while ((length = dataInputStream.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
